@echo off
echo Building Useful Tools for Windows...
echo Cleaning up...
rmdir /s /q dist
echo Installing Dependencies...
bun install
pip install uv
uv pip install git+https://github.com/bottlepy/bottle.git
uv pip install wheel
uv pip install -r requirements.txt
echo Building the UI...
bun run build
echo Copying the files...
copy main.py tmp && copy icon.ico tmp && mkdir tmp\scripts && copy scripts\* tmp\scripts\
echo Installing Inno Setup...
winget install --id=JRSoftware.InnoSetup -e -s winget
echo Installing NanaZip...
winget install --id=M2Team.NanaZip -e -s winget
echo Building the executable folder...
cd tmp
python -m eel main.py web --clean --noconfirm --onedir --windowed --icon icon.ico --name "Useful Tools for Windows"
cd "dist\Useful Tools for Windows\"
echo Copying the scripts to executable folder...
mkdir scripts
copy ..\..\scripts\* scripts\
echo Zipping the portable edition...
7z a -r ..\..\..\dist\Useful_Tools_For_Windows_Portable.zip *
cd ..\..\..
echo Adding license to the zip file...
7z a dist\Useful_Tools_For_Windows_Portable.zip LICENSE.txt
echo Building the installer...
"%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe" setup.iss
"%LOCALAPPDATA%\Programs\Inno Setup 6\ISCC.exe" setup.iss
echo Cleaning up...
rmdir /s /q tmp
echo Done!
